/**
 * outsider.com.cn Inc.
 * Copyright (c) 2011-2022 All Rights Reserved.
 */
package com.yuanmeng.common.core.enums;

import com.yuanmeng.common.core.exception.ServiceException;

import lombok.Getter;

/**
 * @author outsider
 * @version Id: StatusEnum.java, v 0.1 2022/6/1 17:16 outsider Exp $$
 */
@Getter
public enum VideoOperatorTypeEnum {
    PLAY(0, "PLAY","播放"),

    LIKE(1,  "LIKE","喜欢"),

    FORWARD(2, "FORWARD", "分享"),

    UN_LIKE(-1, "UN_LIKE","取消喜欢"),

    FOLLOW(3, "FOLLOW","关注"),

    UN_FOLLOW(-3, "UN_FOLLOW","取消关注");

    private Integer value;

    private String code;

    private String message;

    VideoOperatorTypeEnum(Integer value, String code, String message) {
        this.code = code;
        this.value = value;
        this.message = message;
    }

    public static void validateVideoOperatorType(String operatorType) {
        int num = 0;
        for(VideoOperatorTypeEnum ENUM : VideoOperatorTypeEnum.values()) {
            if(ENUM.code.equals(operatorType)) {
                num ++;
            }
        }
        if(num == 0) {
            throw new ServiceException("请求参数非法：operatorType");
        }
    }

    public static Integer getValueByCode(String operatorType) {
        for(VideoOperatorTypeEnum ENUM : VideoOperatorTypeEnum.values()) {
            if(ENUM.code.equals(operatorType)) {
                return ENUM.getValue();
            }
        }
        return null;
    }
}